package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.web.CategoryVo;
import com.atguigu.gmall.feign.product.CategoryFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @author:ahang
 * @create:2022-10-03 20:42
 * @Description:
 */
@Controller
public class IndexController {

    @Autowired
    CategoryFeignClient CategoryFeignClient;

    @GetMapping({"/","/index.html"})
    public String index(Model model){
        //RPC远程调用
        Result<List<CategoryVo>> categorys = CategoryFeignClient.getCategorys();
        List<CategoryVo> list = categorys.getData();
        model.addAttribute("list",list);
        return "index/index";
    }
}
